using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player_CounterAttackState : PlayerStateBase
{
    private Player_Combat playerCombat;
    private bool hasCounterAttack;
    public Player_CounterAttackState(Player player, StateMachine stateMachine, string animName) : base(player, stateMachine, animName)
    {
        playerCombat = player.GetComponent<Player_Combat>();
    }
    public override void Enter()
    {
        base.Enter();
        stateTimer = playerCombat.GetCounterAttackDuration();
        hasCounterAttack = playerCombat.CounterAttackPerformed();
        animator.SetBool("CounterAttack_Perform", hasCounterAttack);
        
    }
    public override void Update()
    {
        base.Update();
        if ((stateTimer < 0f && !hasCounterAttack) || triggerCalled)
        {
            stateMachine.ChangeState(player.idleState);
        }
        player.SetVelocity(0, rb.velocity.y);
    }
}
